package com.softline.documentsmall.controller;

import com.softline.documentsmall.entity.ErrorCorrection;
import com.softline.documentsmall.entity.ErrorCorrectionDetails;
import com.softline.documentsmall.entity.ErrorCorrectionDetailsVO;
import com.softline.documentsmall.entity.ThumbsUp;
import com.softline.documentsmall.ret.BusinessErrorEnum;
import com.softline.documentsmall.ret.ReturnVO;
import com.softline.documentsmall.ret.ReturnVOUtils;
import com.softline.documentsmall.service.ErrorCorrectionDetailsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: documentsmall
 * @description: 纠错controller
 * @author: wmj
 * @create: 2020-12-15
 * @ClassName: ErrorCorrectionDetailsController
 */

@Api(value="纠错相关接口",tags={"纠错相关接口"})
@RestController
@RequestMapping("/error/correction/details")
@CrossOrigin(allowCredentials = "true",allowedHeaders = "*")
public class ErrorCorrectionDetailsController {

    @Autowired
    ErrorCorrectionDetailsService errorCorrectionDetailsService;


    @ApiOperation(value="新增", notes = "新增")
    @PostMapping(value = "/add")
    public ReturnVO add(@RequestBody ErrorCorrectionDetailsVO errorCorrectionDetailsVO){
        errorCorrectionDetailsService.add(errorCorrectionDetailsVO);
        return ReturnVOUtils.success("纠错成功");
    }

    @ApiOperation(value="术语纠错后台审核列表查询", notes = "术语纠错后台审核列表查询")
    @GetMapping(value = "/selectCorrectionList")
    public ReturnVO selectCorrectionList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, @RequestParam(name = "type", defaultValue = "en") String type){
       List<ErrorCorrectionDetails> errorCorrectionDetailsList= errorCorrectionDetailsService.selectCorrectionList(pageNo,pageSize,type);
        if (ObjectUtils.isEmpty(errorCorrectionDetailsList)) {
            return ReturnVOUtils.businessFail(BusinessErrorEnum.FAIL);
        } else {
            return ReturnVOUtils.success(errorCorrectionDetailsList);
        }
    }
}
